Skip to main content

backgroundColor

Type

property

Summary

Specifies an object's background color.

Syntax

set the backgroundColor of <object> to {empty | <colorName> | <RGBColor>}
set the backgroundColor [of <chunk>] [of <line>] of <field> to {empty| <colorName> | <RGBColor>}

Description

Use the backgroundColor property to change the background of a window, or the color that fills an object, or to change the background color of text for a highlighted effect.

By default, the backgroundColor for all objects is empty.

Setting the backgroundColor of an object to empty allows the backgroundColor of the object's owner to show through. Use the effective keyword to find out what color is used for the object, even if its own backgroundColor is empty.

If an object's backgroundPattern is set, the pattern is shown instead of the color specified by backgroundColor. The setting of the backgroundColor property has different effects, depending on the object type:

  • The backgroundColor of a stack or card fills the entire stack window, as well as determining the backgroundColor of each object in the stack or card that does not have its own backgroundColor.
Cross-platform note

On Mac OS, OS X, and Windows systems, if the backgroundColor of all objects in the object hierarchy is empty, the background color set by the system is used.

  • The backgroundColor of a group determines the backgroundColor of each object in the group that does not have its own backgroundColor.

  • The backgroundColor of a button fills the area inside the button's outline. If the button's style is "checkbox", the backgroundColor fills the checkbox. If the button's style is "radioButton", the backgroundColor has no effect. If the button is a tabbed button, the backgroundColor fills the tab area and the frontmost tab, but does not affect the other tabs.

Cross-platform note

If the lookAndFeel is set to "Appearance Manager", standard and rectangle buttons are drawn by the operating system if the backgroundColor and backgroundPattern of the button is empty. (In this case, none of the button's color properties have an effect except for the foregroundColor or foregroundPattern.) Otherwise, the button is drawn by LiveCode. If the lookAndFeel is "Appearance Manager", button menus whose menuMode is set to "option" or "comboBox" are always drawn by the operating system, and the setting of the backgroundColor does not affect them.

  • The backgroundColor of a field fills the area inside the field's outline. If you set the backgroundColor of a chunk of a field, only that chunk is affected. For example, to create a "highlighter pen" effect on a single word, set the word's backgroundColor to yellow. If a chunk of text contains runs of text with more than one background color, the backgroundColor of that chunk reports "mixed".

If a field's backgroundColor is empty and the lookAndFeel property is set to "Macintosh", "Appearance Manager", or "Windows 95", the field background is white, instead of inheriting its owner's color.

  • The backgroundColor of a scrollbar fills the arrow boxes at the ends of the scrollbar.

  • The backgroundColor of a graphic is displayed inside the graphic's border if the graphic's fill property is true. If the graphic's fill is false, the setting of the backgroundColor has no effect.

  • The backgroundColor of an EPS object fills the object's rectangle.

  • The backgroundColor of an image is the second color in the image's color palette.

  • The backgroundColor of a player, audio clip, or video clip has no effect.

The ability to use the system background color was introduced in version 1.1. In previous versions, if the backgroundColor of all objects in the object hierarchy was empty, a light gray color was used.

Parameters

NameTypeDescription

colorName

Any standard color name.

rgbColor

Consists of three comma-separated integers between zero and 255, specifying the level of each of red, green, and blue; or an HTML-style color consisting of a hash mark (#) followed by three hexadecimal numbers, one for each of red, green, and blue.

Examples

set the backgroundColor of last button to "white"
set the backgroundColor of graphic 2 to 128,128,128
set the backgroundColor of word thisWord of field "Help!" to "#808080"
get the effective backgroundColor of this card
-- Set the background color of a paragraph of text in a field
set the backgroundColor of line 1 of field 1 to red

object: button, image, field, stack, graphic

property: leftIndent, topColor, borderWidth, vgrid, backgroundPattern, textAlign, dontWrap, formattedText, spaceAbove, menuMode, brushColor, listBehavior, listIndent, linkColor, hidden, textSize, firstIndent, tabstops, spaceBelow, listStyle, style, rightIndent, listDepth, hgrid, foregroundColor, linkHiliteColor, hScrollbar, owner, lookAndFeel, borderColor, formattedWidth

command: answer color, group

glossary: object, video clip, property, tabbed button, highlight, stack window, object type, Mac OS, OS X, chunk, object hierarchy, color palette, button menu, keyword, audio clip, EPS, owner, Windows, word

keyword: image, effective, field, button, word, player, card, scrollbar, graphic

Compatibility and Support

Introduced

LiveCode 1.0

OS

mac

windows

linux

ios

android

Platforms

desktop

server

mobile

Thank you for your feedback!

Was this page helpful?